home *** CD-ROM | disk | FTP | other *** search
/ Practical Internet 2002 February / Practical Internet February 2002.iso / pc / Software / Browsing / httrack-3.09e2.exe / {app} / src / htstools.c < prev    next >
Encoding:
C/C++ Source or Header  |  2001-11-07  |  16.7 KB  |  651 lines

  1. /* ------------------------------------------------------------ */
  2. /*
  3. HTTrack Website Copier, Offline Browser for Windows and Unix
  4. Copyright (C) Xavier Roche and other contributors
  5.  
  6. This program is free software; you can redistribute it and/or
  7. modify it under the terms of the GNU General Public License
  8. as published by the Free Software Foundation; either version 2
  9. of the License, or any later version.
  10.  
  11. This program is distributed in the hope that it will be useful,
  12. but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  14. GNU General Public License for more details.
  15.  
  16. You should have received a copy of the GNU General Public License
  17. along with this program; if not, write to the Free Software
  18. Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
  19.  
  20.  
  21. Important notes:
  22.  
  23. - We hereby ask people using this source NOT to use it in purpose of grabbing
  24. emails addresses, or collecting any other private information on persons.
  25. This would disgrace our work, and spoil the many hours we spent on it.
  26.  
  27.  
  28. Please visit our Website: http://www.httrack.com
  29. */
  30.  
  31.  
  32. /* ------------------------------------------------------------ */
  33. /* File: httrack.c subroutines:                                 */
  34. /*       various tools (filename analyzing ..)                  */
  35. /* Author: Xavier Roche                                         */
  36. /* ------------------------------------------------------------ */
  37.  
  38. #include "htstools.h"
  39.  
  40. /* specific definitions */
  41. #include "htsbase.h"
  42. #include <stdio.h>
  43. #include <stdlib.h>
  44. #include <string.h>
  45. #include <ctype.h>
  46. /* END specific definitions */
  47.  
  48.  
  49. // forme α partir d'un lien et du contexte (origin_fil et origin_adr d'o∙ il est tirΘ) adr et fil
  50. // [adr et fil sont des buffers de 1ko]
  51. // 0 : ok
  52. // -1 : erreur
  53. // -2 : protocole non supportΘ (ftp)
  54. int ident_url_relatif(char *lien,char* origin_adr,char* origin_fil,char* adr,char* fil) {
  55.   int ok=0;
  56.   int scheme=0;
  57.  
  58.   adr[0]='\0'; fil[0]='\0';    //effacer buffers
  59.  
  60.   // lien non vide!
  61.   if (strnotempty(lien)==0) return -1;    // erreur!
  62.  
  63.   // Scheme?
  64.   {
  65.     char* a=lien;
  66.     while (isalpha((unsigned char)*a))
  67.       a++;
  68.     if (*a == ':')
  69.       scheme=1;
  70.   }
  71.  
  72.   // filtrer les parazites (mailto & cie)
  73.   if (    (strfield(lien,"http://"))   // scheme+//
  74.             || (strfield(lien,"file://"))   // scheme+//
  75.             || (strfield(lien,"//"))        // // sans scheme
  76.        ) {
  77.     if (ident_url_absolute(lien,adr,fil)==-1) {        
  78.       ok=-1;    // erreur URL
  79.     }
  80.   }
  81.   else if (strfield(lien,"ftp://")) {
  82.     // Note: ftp:foobar.gif is not valid
  83.     if (ftp_available()) {     // ftp supportΘ
  84.       if (ident_url_absolute(lien,adr,fil)==-1) {        
  85.         ok=-1;    // erreur URL
  86.       }
  87.     } else {
  88.       ok=-2;  // non supportΘ
  89.     }
  90.   } else if (scheme) {
  91.     ok=-1;      // unknows scheme
  92.   } else {    // c'est un lien relatif
  93.     char* a;
  94.     
  95.     // On forme l'URL complΦte α partie de l'url actuelle
  96.     // et du chemin actuel si besoin est.
  97.     
  98.     // copier adresse
  99.     if (((int) strlen(origin_adr)<HTS_URLMAXSIZE) && ((int) strlen(origin_fil)<HTS_URLMAXSIZE) && ((int) strlen(lien)<HTS_URLMAXSIZE)) {
  100.       strcpy(adr,origin_adr);    // mΩme adresse
  101.  
  102.       /* scheme */
  103.       if (strfield(lien,"http:"))
  104.         lien+=5;
  105.  
  106.       if (*lien!='/') {  // sinon c'est un lien absolu
  107.         a=strchr(origin_fil,'?');
  108.         if (!a) a=origin_fil+strlen(origin_fil);
  109.         while((*a!='/') && ( ((int) a) > ((int) origin_fil)) ) a--;
  110.         if (*a=='/') {    // ok on a un '/'
  111.           if ( (((int) a)-((int) origin_fil)+1+strlen(lien)) < HTS_URLMAXSIZE) {
  112.             // copier chemin
  113.             strncpy(fil,origin_fil,((int) a)-((int) origin_fil)+1);
  114.             *(fil + ((int) a)-((int) origin_fil)+1)='\0';
  115.             
  116.             // copier chemin relatif
  117.             if (((int) strlen(fil)+(int) strlen(lien))<HTS_URLMAXSIZE) {
  118.               strcat(fil,lien + ((*lien=='/')?1:0) );      
  119.               // simplifier url pour les ../
  120.               fil_simplifie(fil);
  121.             } else
  122.               ok=-1;    // erreur
  123.           } else {    // erreur
  124.             ok=-1;    // erreur URL
  125.           }
  126.         } else {    // erreur
  127.           ok=-1;    // erreur URL
  128.         }
  129.       } else { // chemin absolu
  130.         // copier chemin directement
  131.         strcat(fil,lien);      
  132.       }  // *lien!='/'
  133.     } else
  134.       ok=-1;
  135.     
  136.   }  // test news: etc.
  137.  
  138.   // case insensitive pour adresse
  139.   {
  140.     char *a=jump_identification(adr);
  141.     while(*a) {
  142.       if ((*a>='A') && (*a<='Z'))
  143.         *a+='a'-'A';       
  144.       a++;
  145.     }
  146.   }
  147.   
  148.   return ok;
  149. }
  150.  
  151.  
  152.  
  153.  
  154.  
  155. // crΘer dans s, α partir du chemin courant curr_fil, le lien vers link (absolu)
  156. // un ident_url_relatif a dΘja ΘtΘ fait avant, pour que link ne soit pas un chemin relatif
  157. int lienrelatif(char* s,char* link,char* curr_fil) {
  158.   char _curr[HTS_URLMAXSIZE*2];
  159.   char newcurr_fil[HTS_URLMAXSIZE*2],newlink[HTS_URLMAXSIZE*2];
  160.   char* curr;
  161.   //int n=0;
  162.   char* a;
  163.   int slash=0;
  164.   //
  165.   newcurr_fil[0]='\0'; newlink[0]='\0';
  166.   //
  167.  
  168.   // patch: Θliminer les ? (paramΦtres) sinon bug
  169.   if ( (a=strchr(curr_fil,'?')) ) {
  170.     strncat(newcurr_fil,curr_fil,(int) a-(int) curr_fil);
  171.     curr_fil = newcurr_fil;
  172.   }
  173.   if ( (a=strchr(link,'?')) ) {
  174.     strncat(newlink,link,(int) a-(int) link);
  175.     link = newlink;
  176.   }
  177.  
  178.   // recopier uniquement le chemin courant
  179.   curr=_curr;
  180.   strcpy(curr,curr_fil);
  181.   if ((a=strchr(curr,'?'))==NULL)  // couper au ? (params)
  182.     a=curr+strlen(curr)-1;         // pas de params: aller α la fin
  183.   while((*a!='/') && ((int) a>(int) curr)) a--;       // chercher dernier / du chemin courant
  184.   if (*a=='/') *(a+1)='\0';                           // couper dernier /
  185.   
  186.   // "effacer" s
  187.   s[0]='\0';
  188.   
  189.   // sauter ce qui est commun aux 2 chemins
  190.   {
  191.     char *l,*c;
  192.     if (*link=='/') link++;  // sauter slash
  193.     if (*curr=='/') curr++;
  194.     l=link;
  195.     c=curr;
  196.     // couper ce qui est commun
  197. #if HTS_CASSE
  198.     while ((*link==*curr) && (*link!=0)) {link++; curr++; }
  199. #else
  200.     while ((streql(*link,*curr)) && (*link!=0)) {link++; curr++; }
  201. #endif
  202.     // mais on veut un rΘpertoirer entier!
  203.     // si on a /toto/.. et /toto2/.. on ne veut pas sauter /toto !
  204.     while(((*link!='/') || (*curr!='/')) && ((int) link>(int) l)) { link--; curr--; }
  205.     //if (*link=='/') link++;
  206.     //if (*curr=='/') curr++;
  207.   }
  208.   
  209.   // calculer la profondeur du rΘpertoire courant et remonter
  210.   // LES ../ ONT ETE SIMPLIFIES
  211.   a=curr;
  212.   if (*a=='/') a++;
  213.   while(*a) if (*(a++)=='/') strcat(s,"../");
  214.   //if (strlen(s)==0) strcat(s,"/");
  215.  
  216.   if (slash) strcat(s,"/");    // garder absolu!!
  217.   
  218.   // on est dans le rΘpertoire de dΘpart, copier
  219.   strcat(s,link + ((*link=='/')?1:0) );
  220.  
  221.   // on a maintenant une chaine de la forme ../../test/truc.html  
  222.   return 0;
  223. }
  224.  
  225.  
  226. // conversion chemin de fichier/dossier vers 8-3
  227. void long_to_83(char* n83,char* save) {
  228.   n83[0]='\0';
  229.  
  230.   while(*save) {
  231.     char fn83[16],fnl[256];
  232.     int i=0;
  233.     while((save[i]) && (save[i]!='/')) { fnl[i]=save[i]; i++; }
  234.     fnl[i]='\0';
  235.     // conversion
  236.     longfile_to_83(fn83,fnl);
  237.     strcat(n83,fn83);
  238.  
  239.     save+=i;
  240.     if (*save=='/') { strcat(n83,"/"); save++; }
  241.   }
  242. }
  243.  
  244.  
  245. // conversion nom de fichier/dossier vers 8-3
  246. void longfile_to_83(char* n83,char* save) {
  247.   int i=0,j=0;
  248.   char nom[8+1]="";
  249.   char ext[3+1]="";
  250.   
  251.   while((i<8) && (save[j]) && (save[j]!='.')) { if (save[j]!=' ') { nom[i]=save[j]; i++; } j++; }  // recopier nom
  252.   nom[i]='\0';
  253.   if (save[j]) {  // il reste au moins un point
  254.     i=strlen(save)-1;
  255.     while((i>0) && (save[i]!='.') && (save[i]!='/')) i--;    // rechercher dernier .
  256.     if (save[i]=='.') {  // point!
  257.       int j=0;
  258.       i++;
  259.       while((j<3) && (save[i]) ) { if (save[i]!=' ') { ext[j]=save[i]; j++; } i++; }
  260.       ext[j]='\0';
  261.     }
  262.   }
  263.   // corriger vers 8-3
  264.   n83[0]='\0';
  265.   strncat(n83,nom,8);
  266.   if (strnotempty(ext)) {
  267.     strcat(n83,".");
  268.     strncat(n83,ext,3);    
  269.   }
  270. }
  271.  
  272. // Θcrire backblue.gif
  273. int verif_backblue(char* base) {
  274.   static int done=0;
  275.   int ret=0;
  276.   //
  277.   if (!base) {   // init
  278.     done=0;
  279.     return 0;
  280.   }
  281.   if ( (!done)
  282.     || (fsize(fconcat(base,"backblue.gif")) != HTS_DATA_BACK_GIF_LEN)) {
  283.     FILE* fp = filecreate(fconcat(base,"backblue.gif"));
  284.     done=1;
  285.     if (fp) {
  286.       if (fwrite(HTS_DATA_BACK_GIF,HTS_DATA_BACK_GIF_LEN,1,fp) != HTS_DATA_BACK_GIF_LEN)
  287.         ret=1;
  288.       fclose(fp);
  289.       usercommand(0,NULL,fconcat(base,"backblue.gif"));
  290.     } else
  291.       ret=1;
  292.     //
  293.     fp = filecreate(fconcat(base,"fade.gif"));
  294.     if (fp) {
  295.       if (fwrite(HTS_DATA_FADE_GIF,HTS_DATA_FADE_GIF_LEN,1,fp) != HTS_DATA_FADE_GIF_LEN)
  296.         ret=1;
  297.       fclose(fp);
  298.       usercommand(0,NULL,fconcat(base,"fade.gif"));
  299.     } else
  300.       ret=1;
  301.   } 
  302.   return ret;
  303. }
  304.  
  305. // flag
  306. int verif_external(int nb,int test) {
  307.   static int status[2]={1,1};
  308.   if (!test)
  309.     status[nb]=1;   // reset
  310.   else if (status[nb]) {
  311.     status[nb]=0;
  312.     return 1;
  313.   }
  314.   return 0;
  315. }
  316.  
  317.  
  318. // recherche chaεne de type truc<espaces>=
  319. // renvoi dΘcalage α effectuer ou 0 si non trouvΘ
  320. /* SECTION OPTIMISEE:
  321. #define rech_tageq(adr,s) ( \
  322.   ( (*(adr-1)=='<') || (is_space(*(adr-1))) ) ? \
  323.     ( (streql(*adr,*s)) ? \
  324.       (__rech_tageq(adr,s)) \
  325.       : 0 \
  326.     ) \
  327.     : 0\
  328.   )
  329. */
  330. /*
  331. HTS_INLINE int rech_tageq(const char* adr,const char* s) { 
  332.   if ( (*(adr-1)=='<') || (is_space(*(adr-1))) ) {   // <tag < tag etc
  333.     if (streql(*adr,*s)) {                           // tester premier octet (optimisation)
  334.       return __rech_tageq(adr,s);
  335.     }
  336.   }
  337.   return 0;
  338. }
  339. */
  340. // DeuxiΦme partie
  341. HTS_INLINE int __rech_tageq(const char* adr,const char* s) { 
  342.   int p;
  343.   p=strfield(adr,s);
  344.   if (p) {
  345.     while(is_space(adr[p])) p++;
  346.     if (adr[p]=='=') {
  347.       return p+1;
  348.     }
  349.   }
  350.   return 0;
  351. }
  352. // same, but check begining of adr wirh s (for <object src="bar.mov" .. hotspot123="foo.html">)
  353. HTS_INLINE int __rech_tageqbegdigits(const char* adr,const char* s) { 
  354.   int p;
  355.   p=strfield(adr,s);
  356.   if (p) {
  357.     while(isdigit((unsigned char)adr[p]))  p++;      // jump digits
  358.     while(is_space(adr[p])) p++;
  359.     if (adr[p]=='=') {
  360.       return p+1;
  361.     }
  362.   }
  363.   return 0;
  364. }
  365.  
  366. // tag sans =
  367. HTS_INLINE int rech_sampletag(const char* adr,const char* s) { 
  368.   register int p;
  369.   if ( (*(adr-1)=='<') || (is_space(*(adr-1))) ) {   // <tag < tag etc
  370.     p=strfield(adr,s);
  371.     if (p) {
  372.       if (!isalnum((unsigned char)adr[p])) {  // <srcbis n'est pas <src
  373.         return 1;
  374.       }
  375.       return 0;
  376.     }
  377.   }
  378.   return 0;
  379. }
  380.  
  381. // teste si le tag contenu dans from est Θgal α "tag"
  382. HTS_INLINE int check_tag(char* from,const char* tag) {
  383.   char* a=from+1;
  384.   int i=0;
  385.   char s[256];
  386.   while(is_space(*a)) a++;
  387.   while((isalnum((unsigned char)*a) || (*a=='/')) && (i<250)) { s[i++]=*a; a++; }
  388.   s[i++]='\0';
  389.   return (strfield2(s,tag));  // comparer
  390. }
  391.  
  392. // teste si un fichier dΘpasse le quota
  393. int istoobig(LLint size,LLint maxhtml,LLint maxnhtml,char* type) {
  394.   int ok=1;
  395.   if (size>0) {
  396.     if (is_hypertext_mime(type)) {
  397.       if (maxhtml>0) {
  398.         if (size>maxhtml)
  399.           ok=0;
  400.       }
  401.     } else {
  402.       if (maxnhtml>0) {
  403.         if (size>maxnhtml)
  404.           ok=0;
  405.       }
  406.     }
  407.   }
  408.   return (!ok);
  409. }
  410.  
  411.  
  412. int hts_buildtopindex(char* path,char* binpath) {
  413.   FILE* fpo;
  414.   int retval=0;
  415.   char rpath[1024*2];
  416.   char *toptemplate_header=NULL,*toptemplate_body=NULL,*toptemplate_footer=NULL;
  417.   
  418.   // et templates html
  419.   toptemplate_header=readfile_or(fconcat(binpath,"httrack/topindex-header.html"),HTS_INDEX_HEADER);
  420.   toptemplate_body=readfile_or(fconcat(binpath,"httrack/topindex-body.html"),HTS_INDEX_BODY);
  421.   toptemplate_footer=readfile_or(fconcat(binpath,"httrack/topindex-footer.html"),HTS_INDEX_FOOTER);
  422.   
  423.   if (toptemplate_header && toptemplate_body && toptemplate_footer) {
  424.     
  425.     strcpy(rpath,path);
  426.     if (rpath[0]) {
  427.       if (rpath[strlen(rpath)-1]=='/')
  428.         rpath[strlen(rpath)-1]='\0';
  429.     }
  430.     
  431.     fpo=fopen(fconcat(rpath,"/index.html"),"wb");
  432.     if (fpo) {
  433.       find_handle h;
  434.       verif_backblue(concat(rpath,"/"));    // gΘnΘrer gif
  435.       // Header
  436.       fprintf(fpo,toptemplate_header,
  437.         "<!-- Mirror and index made by HTTrack Website Copier/"HTTRACK_VERSION" "HTTRACK_AFF_AUTHORS" -->"
  438.         );
  439.       
  440.       h = hts_findfirst(rpath);
  441.       if (h) {
  442.         do {
  443.           if (hts_findisdir(h)) {
  444.             char iname[HTS_URLMAXSIZE*2],iname2[HTS_URLMAXSIZE*2];
  445.             strcpy(iname,rpath);
  446.             strcat(iname,"/");
  447.             strcat(iname,hts_findgetname(h));
  448.             strcpy(iname2,iname);
  449.             strcat(iname,"/index.html");
  450.             strcat(iname2,"/hts-cache/winprofile.ini");
  451.             if (fexist(iname)) {
  452.               char hname[HTS_URLMAXSIZE*2];
  453.               strcpy(hname,hts_findgetname(h));
  454.               escape_check_url(hname);
  455.               
  456.               // Body
  457.               fprintf(fpo,toptemplate_body,
  458.                 hname,
  459.                 hts_findgetname(h)
  460.                 );
  461.             }
  462.             
  463.           }
  464.         } while(hts_findnext(h));
  465.         hts_findclose(h);
  466.         retval=1;
  467.       }
  468.       
  469.       // Footer
  470.       fprintf(fpo,toptemplate_footer,
  471.         "<!-- Mirror and index made by HTTrack Website Copier/"HTTRACK_VERSION" "HTTRACK_AFF_AUTHORS" -->"
  472.         );
  473.       
  474.       fclose(fpo);
  475.       
  476.     }
  477.     
  478.   }
  479.  
  480.   if (toptemplate_header)
  481.     freet(toptemplate_header);
  482.   if (toptemplate_body)
  483.     freet(toptemplate_body);
  484.   if (toptemplate_footer)
  485.     freet(toptemplate_footer);
  486.   
  487.   return retval;
  488. }
  489.  
  490.  
  491.  
  492.  
  493. // Portable directory find functions
  494. /*
  495. // Example:
  496. find_handle h = hts_findfirst("/tmp");
  497. if (h) {
  498.   do {
  499.     if (hts_findisfile(h))
  500.       printf("File: %s (%d octets)\n",hts_findgetname(h),hts_findgetsize(h));
  501.     else if (hts_findisdir(h))
  502.       printf("Dir: %s\n",hts_findgetname(h));
  503.   } while(hts_findnext(h));
  504.   hts_findclose(h);
  505. }
  506. */
  507. find_handle hts_findfirst(char* path) {
  508.   if (path) {
  509.     if (strnotempty(path)) {
  510.       find_handle_struct* find = (find_handle_struct*) calloc(1,sizeof(find_handle_struct));
  511.       if (find) {
  512.         bzero((char *)find, sizeof(find_handle_struct));
  513. #if HTS_WIN
  514.         {
  515.           char rpath[1024*2];
  516.           strcpy(rpath,path);
  517.           if (rpath[0]) {
  518.             if (rpath[strlen(rpath)-1]!='\\')
  519.               strcat(rpath,"\\");
  520.           }
  521.           strcat(rpath,"*.*");
  522.           find->handle = FindFirstFile(rpath,&find->hdata);
  523.           if (find->handle != INVALID_HANDLE_VALUE)
  524.             return find;
  525.         }
  526. #else
  527.         strcpy(find->path,path);
  528.         {
  529.           if (find->path[0]) {
  530.             if (find->path[strlen(find->path)-1]!='/')
  531.               strcat(find->path,"/");
  532.           }
  533.         }
  534.         find->hdir=opendir(path);
  535.         if (find->hdir != NULL) {
  536.           if (hts_findnext(find) == 1)
  537.             return find;
  538.         }
  539. #endif
  540.         free((void*)find);
  541.       }
  542.     }
  543.   }
  544.   return NULL;   
  545. }
  546. int hts_findnext(find_handle find) {
  547.   if (find) {
  548. #if HTS_WIN
  549.     if ( (FindNextFile(find->handle,&find->hdata)))
  550.       return 1;
  551. #else
  552.     bzero((char *)&(find->filestat), sizeof(find->filestat));
  553.     if ((find->dirp=readdir(find->hdir)))
  554.       if (find->dirp->d_name)
  555.         if (!stat(concat(find->path,find->dirp->d_name),&find->filestat))
  556.           return 1;
  557. #endif
  558.   }
  559.   return 0;
  560. }
  561. int hts_findclose(find_handle find) {
  562.   if (find) {
  563. #if HTS_WIN
  564.     if (find->handle) {
  565.       FindClose(find->handle);
  566.       find->handle=NULL;
  567.     }
  568. #else
  569.     if (find->hdir) {
  570.       closedir (find->hdir);
  571.       find->hdir=NULL;
  572.     }
  573. #endif
  574.     free((void*)find);
  575.   }
  576.   return 0;
  577. }
  578. char* hts_findgetname(find_handle find) {
  579.   if (find) {
  580. #if HTS_WIN
  581.     return find->hdata.cFileName;
  582. #else
  583.     if (find->dirp)
  584.       return find->dirp->d_name;
  585. #endif
  586.   }
  587.   return NULL;
  588. }
  589. int hts_findgetsize(find_handle find) {
  590.   if (find) {
  591. #if HTS_WIN
  592.     return find->hdata.nFileSizeLow;
  593. #else
  594.     return find->filestat.st_size;
  595. #endif
  596.   }
  597.   return -1;
  598. }
  599. int hts_findisdir(find_handle find) {
  600.   if (find) {
  601.     if (!hts_findissystem(find)) {
  602. #if HTS_WIN
  603.       if (find->hdata.dwFileAttributes  & FILE_ATTRIBUTE_DIRECTORY)
  604.         return 1;
  605. #else
  606.       if (S_ISDIR(find->filestat.st_mode))
  607.         return 1;
  608. #endif
  609.     }
  610.   }
  611.   return 0;
  612. }
  613. int hts_findisfile(find_handle find) {
  614.   if (find) {
  615.     if (!hts_findissystem(find)) {
  616. #if HTS_WIN
  617.       if (!(find->hdata.dwFileAttributes  & FILE_ATTRIBUTE_DIRECTORY))
  618.         return 1;
  619. #else
  620.       if (S_ISREG(find->filestat.st_mode))
  621.         return 1;
  622. #endif
  623.     }
  624.   }
  625.   return 0;
  626. }
  627. int hts_findissystem(find_handle find) {
  628.   if (find) {
  629. #if HTS_WIN
  630.     if (find->hdata.dwFileAttributes  & (FILE_ATTRIBUTE_SYSTEM|FILE_ATTRIBUTE_HIDDEN|FILE_ATTRIBUTE_TEMPORARY))
  631.       return 1;
  632.     else if ( (!strcmp(find->hdata.cFileName,"..")) || (!strcmp(find->hdata.cFileName,".")) )
  633.       return 1;
  634. #else
  635.     if (
  636.       (S_ISCHR(find->filestat.st_mode))
  637.       || 
  638.       (S_ISBLK(find->filestat.st_mode))
  639.       || 
  640.       (S_ISFIFO(find->filestat.st_mode))
  641.       || 
  642.       (S_ISSOCK(find->filestat.st_mode))
  643.       )
  644.       return 1;
  645.     else if ( (!strcmp(find->dirp->d_name,"..")) || (!strcmp(find->dirp->d_name,".")) )
  646.       return 1;
  647. #endif
  648.   }
  649.   return 0;
  650. }
  651.